package org.example.myleet.p725;

import org.example.myleet.Utils.Assert;
import org.example.myleet.Utils.ListNode;
import org.example.myleet.Utils.Parser;

public class Main {
    public static void main(String[] args) {
        Solution solution = new Solution();
        Assert.isTrue("[[1],[2],[3],[],[]]".equals(parseResult(solution.splitListToParts(Parser.parseLinkedList("[1,2,3]"), 5))));
        Assert.isTrue("[[1,2,3,4],[5,6,7],[8,9,10]]".equals(parseResult(solution.splitListToParts(Parser.parseLinkedList("[1,2,3,4,5,6,7,8,9,10]"), 3))));
    }

    private static String parseResult(ListNode[] result) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        for (ListNode listNode : result) {
            if (listNode == null) {
                sb.append('[').append(']').append(',');
            } else {
                sb.append('[').append(listNode.toString()).append(']').append(',');
            }
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append(']');
        return sb.toString();
    }
}
